hello = require "./hello_world"
UserGist = require "./gist"
MyComponent = React.createClass
	getInitialState: ->
		liked: false
		color: "red"
	handleClick: (event) ->
		this.setState liked: !this.state.liked		
		if this.state.color == "red"
			this.setState color: "green"
		else
			this.setState color: "red"
		console.log this.state.liked
	
	render: ->
		text = this.state.liked ? 'like' : 'haven\'t liked';
		if this.state.liked
			text = "like"
		else
			text = "havent\'t liked"
			
		<h1 onClick={this.handleClick} className={this.state.color}>this is MyComponent <p>You {text} this. Click to toggle.</p></h1>

module.exports = React.createClass
	render: ->
		<div>
			<p>组件的组合! </p>
			<UserGist source="https://api.github.com/users/octocat/gists" />
		</div>